package com.bootdo.xiao.qcloudsms;

import com.alibaba.fastjson.JSONException;
import com.bootdo.xiao.util.SmsConstants;
import com.github.qcloudsms.SmsSingleSender;
import com.github.qcloudsms.SmsSingleSenderResult;
import com.github.qcloudsms.httpclient.HTTPException;

import java.io.IOException;

import static com.bootdo.xiao.util.SmsConstants.smsSign;
import static com.bootdo.xiao.util.SmsConstants.templateId;

/**
 * @Auther: liuj
 * @Date: 2019/5/24 17:33
 * @Description:
 */
public class SingleSender {
    public static void main(String[] args){
        try {
            String[] params = {"5678"};
            SmsSingleSender ssender = new SmsSingleSender(SmsConstants.appid, SmsConstants.appkey);
            SmsSingleSenderResult result = ssender.sendWithParam("86", SmsConstants.phoneNumbers[0],
                    templateId, params, smsSign, "", "");  // 签名参数未提供或者为空时，会使用默认签名发送短信
            System.out.println(result);

        } catch (HTTPException e) {
            // HTTP 响应码错误
            e.printStackTrace();
        } catch (JSONException e) {
            // JSON 解析错误
            e.printStackTrace();
        } catch (IOException e) {
            // 网络 IO 错误
            e.printStackTrace();
        }
    }
}
